Quick Start (C++)
Sample Project
See the sample project for detailed implementation
Prerequisites
- Check if your target OS is supported
- Install CMake and make sure its version is 3.5 or later
- Sign in to SeeSo Manage and get a license key & C++ SDK
- For mac os, you need to install XCode or Command Line Tools.
⚠️ Visual Studio 2017 or later is recommended. Previous version may work, but not tested.
Environment Set-Ups
- Log in and download SeeSo C++ SDK from SeeSo SDK Manage
- Extract the downloaded SDK and place it in your C++ project
- Create a CMake project, and add the following to your
CMakeLists.txt
Note that CMake minimum version is 3.5
- Windows
- MacOS
cmake_minimum_required(VERSION 3.5)
project(your_project_name)
add_subdirectory(seeso)
target_link_libraries(your_project_name PUBLIC seeso)
if(WIN32)
add_custom_command(TARGET your_project_name PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${SEESO_DLL}
$<TARGET_FILE_DIR:your_project_name>)
endif()
cmake_minimum_required(VERSION 3.5)
project(your_project_name)
add_subdirectory(seeso)
target_link_libraries(your_project_name PUBLIC seeso)
- You have to change
your_project_name
to your actual project name
Set up is done! You can now proceed to the next step
Steps
Initialize SeeSo SDK
Initialize SeeSo SDK by calling seeso::global_init()
This function must be called at least once within a program before the program calls any other function in SeeSo SDK.
#include "seeso/gaze_tracker.h"
int main() {
try {
seeso::global_init();
} catch (const std::exception& e) {
std::cerr << e.what() << '\n';
return EXIT_FAILURE;
}
}
See API docs for global_init
exceptions.
Authentication
Before you call GazeTracker
's member functions, you must authenticate it with a license key.
You can get a license key at SeeSo Manage
seeso::GazeTracker gaze_tracker;
auto auth_code = gaze_tracker.initialize("LICENSE_KEY");
if (auth_code != 0) {
// authentication has failed!
}
See here if authentication fails.
Add listener
SeeSo SDK's main target is real-time gaze tracking, so its calculation is done asynchronously.
To get the result, you have to implement appropriate interface
Following code is implementing IGazeCallback
to get a gaze result.
#include "seeso/gaze_tracker.h"
class OnGazeListener : public seeso::IGazeCallback {
public:
void OnGaze(uint64_t timestamp,
float x, float y,
SeeSoTrackingState tracking_state,
SeeSoEyeMovementState eye_movement_state) override
{
// x, y are the gaze point
}
};
// ...
OnGazeListener listener;
gaze_tracker.setGazeCallback(&listener);
The x
and y
in the above OnGaze
comes out in millimeters, where it's origin is same as the center of the camera(which shoot the input image).
You can change its value based on other coordinate system, such as pixels in display. See Advanced.
Input an image
An image's color format must be RGB, and it's memory must be contiguous. Current time in milliseconds must be provided too.
Example using OpenCV
const auto current_time = []{
namespace chrono = std::chrono;
return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
};
cv::VideoCapture video(0); // open webcam
cv::Mat frame, input;
while(true) {
video >> frame; // read frame
if (frame.empty()) break;
cv::cvtColor(frame, input, cv::COLOR_BGR2RGB); // convert color format
gaze_tracker.addFrame(current_time(), input.data, input.cols, input.rows);
}
Some input can be ignored for some reasons. See here.